//  数据源和数据集相关的接口

import ajax from '@/ajax/index';
const baseUrl = '/bi';
// const baseUrl = '';

// 获取数据源列表
export const getDataSetApi = (params) => {
  return ajax.get(`${baseUrl}/reportSources/querySourceList`, {
    params: {
      ...params
    }
  });
};

// 添加数据源
export const addSourcesApi = (data) =>
  ajax.post(`${baseUrl}/reportSources/addSources`, data);

/**
 * @description: 获取配置好的数据源- 根据大屏ID,获取数据源列表信息
 * @param {*} data
 * @return {*}
 */
export const getDataSourceListApi = (params) =>
  ajax.get(`${baseUrl}/reportDataset/querySourcesInformation`, {
    params: {
      ...params
    }
  });

// 根据数据源ID,获取表信息
export const getDataSourceTableListApi = (params) =>
  ajax.get(`${baseUrl}/reportDataset/queryTablesInformation`, {
    params: {
      ...params
    }
  });

// 根据数据源ID,获取表信息
export const getDataSourceTableColumnListApi = (params) =>
  ajax.get(`${baseUrl}/reportDataset/queryColumnsInformation`, {
    params: {
      ...params
    }
  });

/**
 * @description: 添加数据集
 * @param {*} data
 * @return {*}
 */
export const addDataSetApi = (data) =>
  ajax.post(`${baseUrl}/reportDataset/addDataSet`, data);

//获取已经配置的大屏数据集列表
export const getScreenHaveConfigDataSetListApi = (params) =>
  ajax.get(`${baseUrl}/reportDataset/queryDataSetList`, {
    params
  });

//获取大屏数据集对应的表字段
export const getDataSetColumnListApi = (params) =>
  ajax.get(`${baseUrl}/reportDataset/queryDataSetColumns`, {
    params
  });

//获取数据集修改的详情接口
export const getScreenDataSetDetailApi = (params) =>
  ajax.get(`${baseUrl}/reportDataset/queryById`, {
    params
  });

//根据数据集ID获取当前数据集已经勾选的字段
export const getDataSetHasCheckedApi = (params) =>
  ajax.get(`${baseUrl}/reportDataset/queryColumnsByDataSetId`, {
    params
  });

// 删除单个数据集
export const deleteDataSetOneApi = (data) =>
  ajax.post(`${baseUrl}/reportDataset/deleteByIds`, data);

// 设置报表数据集字段分组规则
export const setGroupColumnByDataSetIdApi = (data) =>
  ajax.post(`${baseUrl}/reportDataset/setGroupColumnByDataSetId`, data);

//回显分组展示规则
export const setDataSetGroupByDataSetIdApi = (data) =>
  ajax.post(
    `${baseUrl}/reportDataset/setDataSetGroupByDataSetId`,
    data
  );
